# -*- coding: utf-8 -*-

import re
import time

from odoo.http import request


RE_IMAGE_SRC = re.compile(r'(/web/image/\d+/)')


def sanitize_html_field(content, host_url=None):
    if host_url is None:
        host_url = request.httprequest.host_url
    return re.sub(RE_IMAGE_SRC, host_url + r'\1', content)


def now_ts():
    return int(time.time())
